package com.star.eastern.blee.utils

import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface
import android.support.v4.content.ContextCompat.getColor
import android.support.v4.content.ContextCompat.getDrawable
import android.view.Gravity
import android.view.LayoutInflater
import com.star.eastern.blee.R

class AlertUtil {
    companion object {
        fun alertMessage(c:Context) {
            val dialog = android.support.v7.app.AlertDialog.Builder(c)
                    .setTitle("")
                    .setIcon(R.drawable.logo)
                    .setMessage("")
                    .setPositiveButton("ok",null)
                    .setNegativeButton("cancel", null)
                    .show()
            dialog.getButton(android.support.v7.app.AlertDialog.BUTTON_POSITIVE).setTextColor(getColor(c,R.color.button_negative))
            dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(getColor(c,R.color.button_negative))
        }

        fun alertDialog(c:Context): AlertDialog {
            val builder = android.app.AlertDialog.Builder(c)
            val inflater = LayoutInflater.from(c)
            val v = inflater.inflate(R.layout.layout_loading, null)
            val dialog = builder.create()
            val dialogWindow = dialog.window
            dialog.show()
//        dialogWindow.setLayout(400,400)
            dialogWindow.setBackgroundDrawable(getDrawable(c,android.R.color.transparent))
            dialogWindow.setContentView(v)
            dialogWindow.setGravity(Gravity.CENTER)
            return dialog
        }

    }
}